.class public Lcom/htc/android/footprints/utils/SoundPlayer;
.super Ljava/lang/Object;
.source "SoundPlayer.java"


# static fields
.field private static final TAG:Ljava/lang/String; = "SoundUtils"


# instance fields
.field private mContext:Landroid/content/Context;

.field private mPlayer:Landroid/media/MediaPlayer;


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 1
    .parameter "context"

    .prologue
    .line 17
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 18
    iput-object p1, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mContext:Landroid/content/Context;

    .line 19
    new-instance v0, Landroid/media/MediaPlayer;

    invoke-direct {v0}, Landroid/media/MediaPlayer;-><init>()V

    iput-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mPlayer:Landroid/media/MediaPlayer;

    .line 22
    return-void
.end method


# virtual methods
.method public play()V
    .locals 2

    .prologue
    .line 79
    iget-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mPlayer:Landroid/media/MediaPlayer;

    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Landroid/media/MediaPlayer;->seekTo(I)V

    .line 80
    iget-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->start()V

    .line 81
    return-void
.end method

.method public prepareCarmerFocused()V
    .locals 8

    .prologue
    .line 64
    :try_start_0
    iget-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mContext:Landroid/content/Context;

    invoke-virtual {v0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v0

    const v1, 0x7f060001

    invoke-virtual {v0, v1}, Landroid/content/res/Resources;->openRawResourceFd(I)Landroid/content/res/AssetFileDescriptor;

    move-result-object v6

    .line 66
    .local v6, afd:Landroid/content/res/AssetFileDescriptor;
    iget-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mPlayer:Landroid/media/MediaPlayer;

    if-eqz v0, :cond_0

    .line 67
    iget-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->reset()V

    .line 68
    iget-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v6}, Landroid/content/res/AssetFileDescriptor;->getFileDescriptor()Ljava/io/FileDescriptor;

    move-result-object v1

    invoke-virtual {v6}, Landroid/content/res/AssetFileDescriptor;->getStartOffset()J

    move-result-wide v2

    invoke-virtual {v6}, Landroid/content/res/AssetFileDescriptor;->getLength()J

    move-result-wide v4

    invoke-virtual/range {v0 .. v5}, Landroid/media/MediaPlayer;->setDataSource(Ljava/io/FileDescriptor;JJ)V

    .line 70
    iget-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mPlayer:Landroid/media/MediaPlayer;

    const/4 v1, 0x1

    invoke-virtual {v0, v1}, Landroid/media/MediaPlayer;->setAudioStreamType(I)V

    .line 71
    iget-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->prepare()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 76
    .end local v6           #afd:Landroid/content/res/AssetFileDescriptor;
    :cond_0
    :goto_0
    return-void

    .line 73
    :catch_0
    move-exception v0

    move-object v7, v0

    .line 74
    .local v7, ex:Ljava/lang/Exception;
    const-string v0, "SoundUtils"

    const-string v1, "Couldn\'t create focus sound"

    invoke-static {v0, v1, v7}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    goto :goto_0
.end method

.method public prepareCarmerFocusing()V
    .locals 8

    .prologue
    .line 44
    :try_start_0
    iget-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mContext:Landroid/content/Context;

    invoke-virtual {v0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v0

    const v1, 0x7f060002

    invoke-virtual {v0, v1}, Landroid/content/res/Resources;->openRawResourceFd(I)Landroid/content/res/AssetFileDescriptor;

    move-result-object v6

    .line 48
    .local v6, afd:Landroid/content/res/AssetFileDescriptor;
    iget-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mPlayer:Landroid/media/MediaPlayer;

    if-eqz v0, :cond_0

    .line 49
    iget-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->reset()V

    .line 50
    iget-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v6}, Landroid/content/res/AssetFileDescriptor;->getFileDescriptor()Ljava/io/FileDescriptor;

    move-result-object v1

    invoke-virtual {v6}, Landroid/content/res/AssetFileDescriptor;->getStartOffset()J

    move-result-wide v2

    invoke-virtual {v6}, Landroid/content/res/AssetFileDescriptor;->getLength()J

    move-result-wide v4

    invoke-virtual/range {v0 .. v5}, Landroid/media/MediaPlayer;->setDataSource(Ljava/io/FileDescriptor;JJ)V

    .line 53
    iget-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mPlayer:Landroid/media/MediaPlayer;

    const/4 v1, 0x1

    invoke-virtual {v0, v1}, Landroid/media/MediaPlayer;->setAudioStreamType(I)V

    .line 54
    iget-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->prepare()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 59
    .end local v6           #afd:Landroid/content/res/AssetFileDescriptor;
    :cond_0
    :goto_0
    return-void

    .line 56
    :catch_0
    move-exception v0

    move-object v7, v0

    .line 57
    .local v7, ex:Ljava/lang/Exception;
    const-string v0, "SoundUtils"

    const-string v1, "Couldn\'t create focus sound"

    invoke-static {v0, v1, v7}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    goto :goto_0
.end method

.method public prepareCarmerShutter()V
    .locals 8

    .prologue
    .line 26
    :try_start_0
    iget-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mContext:Landroid/content/Context;

    invoke-virtual {v0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v0

    const/high16 v1, 0x7f06

    invoke-virtual {v0, v1}, Landroid/content/res/Resources;->openRawResourceFd(I)Landroid/content/res/AssetFileDescriptor;

    move-result-object v6

    .line 29
    .local v6, afd:Landroid/content/res/AssetFileDescriptor;
    iget-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mPlayer:Landroid/media/MediaPlayer;

    if-eqz v0, :cond_0

    .line 30
    iget-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->reset()V

    .line 31
    iget-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v6}, Landroid/content/res/AssetFileDescriptor;->getFileDescriptor()Ljava/io/FileDescriptor;

    move-result-object v1

    invoke-virtual {v6}, Landroid/content/res/AssetFileDescriptor;->getStartOffset()J

    move-result-wide v2

    invoke-virtual {v6}, Landroid/content/res/AssetFileDescriptor;->getLength()J

    move-result-wide v4

    invoke-virtual/range {v0 .. v5}, Landroid/media/MediaPlayer;->setDataSource(Ljava/io/FileDescriptor;JJ)V

    .line 33
    iget-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mPlayer:Landroid/media/MediaPlayer;

    const/4 v1, 0x1

    invoke-virtual {v0, v1}, Landroid/media/MediaPlayer;->setAudioStreamType(I)V

    .line 34
    iget-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->prepare()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 39
    .end local v6           #afd:Landroid/content/res/AssetFileDescriptor;
    :cond_0
    :goto_0
    return-void

    .line 36
    :catch_0
    move-exception v0

    move-object v7, v0

    .line 37
    .local v7, ex:Ljava/lang/Exception;
    const-string v0, "SoundUtils"

    const-string v1, "Couldn\'t create click sound"

    invoke-static {v0, v1, v7}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    goto :goto_0
.end method

.method public release()V
    .locals 1

    .prologue
    .line 84
    iget-object v0, p0, Lcom/htc/android/footprints/utils/SoundPlayer;->mPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->release()V

    .line 85
    return-void
.end method
